package tds.model29;

import java.util.ArrayList;
import java.util.List;

/**
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName ObjectStructure
 * @Description 一个高层接口，提供访问者visitor访问被访问者Element
 * @author tds
 * @Date 2020/2/8 21:47
 * @version 1.0.0
 */
public class ObjectStructure {

    private List<Element> elements = new ArrayList<>();

    public void attach(Element element){
        elements.add(element);
    }

    public void detach(Element element){
        elements.remove(element);
    }

    public void accept(Vistor vistor){
        for (Element element : elements){
            element.accept(vistor);
        }
    }
}
